﻿using System.Net;
using System.Net.Http;
using System.Web.Http.Filters;
using GC_MU.Site.Api.Models;

namespace GC_MU.Site.Api.Attributes
{
	public class NotImplExceptionFilterAttribute : ExceptionFilterAttribute
	{
		public override void OnException(HttpActionExecutedContext context)
		{
			if (context.Exception != null)
			{
				context.Response = context.Request.CreateResponse(HttpStatusCode.InternalServerError, new ResponseErrorModel
				{
					Meta = new MetaModel
					{
						Code = HttpStatusCode.InternalServerError
					},
					Error = new ErrorModel
					{
						Message = "An internal error occurred."
					},
				});
			}
		}
	}
}